﻿<div class="container">
    <form method="post" action="/Purchase/Buy">
        @{
            var addrs = ViewData["Addrs"] as List<Address>;
            addrs = addrs.OrderByDescending(r => r.IsDefault).ToList();
            var defaultAddr = addrs.FirstOrDefault(r => r.IsDefault);
            var productConfigs = ViewData["ProductConfigs"] as Dictionary<string, string>;
            var total = 0M;
        }
        <div data-halo-id="addressPC_1" data-halo-type="address">
            <div class="order-address OneRow" id="addressPC_1">
                <div class="header-wrapper border-bottom">
                    <h2 class="header-title">
                        确认收货地址
                        <a class="header-operation" rel="noopener noreferrer" target="_blank" href="//member1.taobao.com/member/fresh/deliver_address.htm">管理收货地址</a>
                    </h2>
                </div>
                <div class="address-tips-top"></div>
                <input type="hidden" name="addr" id="addr" value="@($"{defaultAddr.ToString()} ({defaultAddr.Name} 收) {defaultAddr.Phone}")" />
                <div class="address-list">
                    @{
                        for (int i = 0; i < addrs.Count; i++)
                        {
                            var addr = addrs[i];
                            if (addr.IsDefault)
                            {
                                <div class="addr-item-wrapper OneRow addr-selected addr-default">
                                    <div class="inner-infos">
                                        <div class="content-container">
                                            <div class="selected-description">
                                                <i class="marker">&hearts;</i>
                                                <span class="marker-tip">寄送至</span>
                                            </div>
                                            <label dir="ltr" aria-checked="true" class="next-radio-wrapper address-contents checked ">
                                                <span class="next-radio checked" onclick="javascript:CheckAddr(this);">
                                                    <span class="next-radio-inner press"></span>
                                                    <input role="radio" tabindex="0" type="radio" aria-checked="true" class="next-radio-input" checked="">
                                                </span>
                                                <span class="next-radio-label">
                                                    <span class="provinceName">@addr.Province </span>
                                                    <span class="cityName">@addr.City </span>
                                                    <span class="areaName">@addr.District </span>
                                                    <span class="townName">@addr.Street </span>
                                                    <span class="addressDetail">@addr.Detail </span>
                                                    <span class="reciver">（@(addr.Name) 收）</span>
                                                    <span class="mobile">@addr.Phone </span>
                                                    <span class="default-tip">默认地址</span>
                                                </span>
                                            </label>
                                            <a class="set-default" title="设置当前地址为默认">设置为默认收货地址</a>
                                        </div>
                                        <a title="修改地址" class="modify-operation">修改本地址</a>
                                    </div>
                                    <div class="curMarker"></div>
                                </div>
                            }
                            else
                            {
                                <div class="addr-item-wrapper OneRow addr-not-default">
                                    <div class="inner-infos">
                                        <div class="content-container">
                                            <label dir="ltr" aria-checked="false" class="next-radio-wrapper address-contents ">
                                                <span class="next-radio" onclick="javascript:CheckAddr(this);">
                                                    <span class="next-radio-inner unpress"></span>
                                                    <input role="radio" tabindex="0" type="radio" aria-checked="false" class="next-radio-input">
                                                </span>
                                                <span class="next-radio-label">
                                                    <span class="provinceName">@addr.Province </span>
                                                    <span class="cityName">@addr.City </span>
                                                    <span class="areaName">@addr.District </span>
                                                    <span class="townName">@addr.Street </span>
                                                    <span class="addressDetail">@addr.Detail </span>
                                                    <span class="reciver">（@(addr.Name) 收）</span>
                                                    <span class="mobile">@addr.Phone </span>
                                                    <span class="default-tip">默认地址</span>
                                                </span>
                                            </label>
                                            <a class="set-default" title="设置当前地址为默认">设置为默认收货地址</a>
                                        </div>
                                    </div>
                                    <div class="curMarker"></div>
                                </div>
                            }
                        }
                    }
                </div>
                <div class="address-tips OneRow"></div>
                <div class="operations">
                    <a class="operation OneRow" style="font-size:12px;">使用其它地址</a>
                </div>
            </div>
        </div>

        <div data-halo-id="orderDesc_orderDesc_1" data-halo-type="itemHeader">
            <div class="item-headers" id="orderDesc_orderDesc_1">
                <div class="header-wrapper ">
                    <h2 class="header-title">确认订单信息</h2>
                </div>
                <div class="item-headers-wrap item-headers-column-6">
                    <div class="item-headers-content item-headers-0">店铺宝贝</div>
                    <div class="item-headers-content item-headers-1">商品属性</div>
                    <div class="item-headers-content item-headers-2">单价</div>
                    <div class="item-headers-content item-headers-3">数量</div>
                    <div class="item-headers-content item-headers-4">优惠方式</div>
                    <div class="item-headers-content item-headers-5">小计</div>
                </div>
            </div>
        </div>
        @{
            var products = ViewData["Products"] as List<Product>;
            var shops = ViewData["Shops"] as List<Shop>;
            for (int i = 0; i < products.Count; i++)
            {
                var product = products[i];
                var quantity_key = $"quantity_{product.Id}";
                var remark_key = $"remark_{product.Id}";
                var quantity = 1;
                var remark = "";
                if (productConfigs != null || productConfigs.Count > 0)
                {
                    if (productConfigs.ContainsKey(quantity_key))
                    {
                        quantity = int.Parse(productConfigs[quantity_key]);

                    }
                    if (productConfigs.ContainsKey(remark_key))
                    {
                        remark = productConfigs[remark_key];

                    }
                }
                var shop = shops.FirstOrDefault(r => r.Id == product.ShopId);
                total += (product.PreferentialPrice * quantity);
                <input type="hidden" name="productId" value="@(product.Id)" />
                <div id="@(product.Id)" data="[object Object]" extension="[object Object]" class="dinamicx-card-group" style="border: 0px solid black; position: relative; box-sizing: border-box; display: flex; flex-direction: column; align-content: flex-start; flex-shrink: 0;">
                    <div data-halo-id="seller_a805f2fc129a1c05fb8a632a8777f2d2" data-halo-type="seller">
                        <div class="order-orderInfo" id="seller_a805f2fc129a1c05fb8a632a8777f2d2" style="font-size:12px;">
                            <span class="shop-name">店铺:&nbsp;</span>
                            <a href="/Shop/Index?id=@(product.ShopId)" target="_blank" rel="noopener noreferrer" title="" class="order-link shop-url">@(shop.Description)</a>
                            <span class="shop-seller">
                                卖家:&nbsp;
                                <a href="##" target="_blank" rel="noopener noreferrer" title="@(shop.Description)" class="order-link shop-url">@(shop.Name)</a>
                            </span>
                            <span class="ww-light ww-large" data-encode="true" data-nick="@(shop.Name)" data-display="inline" data-icon="large">
                                <a href="" target="_blank" class="ww-inline ww-online" title=""><span></span></a>
                            </span>
                        </div>
                    </div>
                    <div data-halo-id="item_187bb8c6f1e163c55f64eb56fef0eacc" data-halo-type="flex">
                        <div id="item_187bb8c6f1e163c55f64eb56fef0eacc" style="display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; margin: 0px; padding: 0px; background-color: rgb(251, 252, 255); border-bottom: 1px dotted rgb(221, 221, 221);">
                            <div style="padding: 0px;">
                                <div data-halo-id="itemInfoPC_187bb8c6f1e163c55f64eb56fef0eacc" data-halo-type="itemRow">
                                    <div id="itemInfoPC_187bb8c6f1e163c55f64eb56fef0eacc" class="item-row">
                                        <div class="order-itemInfo">
                                            <div class="info-detail info-cell">
                                                <a href="/Product/Detail/@(product.Id)" target="_blank" rel="noopener noreferrer" class="order-link info-cell">
                                                    <img class="info-img" src="@(product.ImageUrl)">
                                                </a>
                                                <div class="info-cell info-msg">
                                                    <a href="/Product/Detail/@(product.Id)" target="_blank" rel="noopener noreferrer" class="order-link info-title">@(product.Name)</a>
                                                    <div class="info-icon-list">
                                                        <div>
                                                            <a href="##" target="_blank" rel="noopener noreferrer" title="如实描述 - 消费者保障服务，卖家承诺商品如实描述" class="order-link icon-main">
                                                                <img src="~/imgs/others/quanyi.png">
                                                            </a>
                                                            <a target="_blank" rel="noopener noreferrer" title="7天无理由退货" class="order-link icon-main"><img></a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="info-sku info-cell">
                                                <p>
                                                    <span class="hd">基础风格：@(product.BasicStyle)</span>
                                                </p>
                                                <p>
                                                    <span class="bd">商品类型：@(product.ProductStyle)</span>
                                                </p>
                                            </div>
                                            <div class="info-price info-cell">@(Math.Round(product.Price, 2))</div>
                                        </div>
                                        <div class="order-quantity">
                                            <div class="quantity-inner">
                                                <p><input type="text" name="quantity_@(product.Id)" id="quantity_@(product.Id)" value="@(quantity)" style="width:40px; border:1px solid lightblue" onchange="javascript:confirmTotalPrice(@(product.Id));" /></p>
                                            </div>
                                        </div>
                                        <div class="item-row__select"><p class="item-row__text">@(product.Preferential > 0 ? Math.Round(product.Preferential * 100, 2).ToString() + "%" : "无优惠")</p></div>
                                        <div class="item-row__price">
                                            <div class="label item-row__price-item">
                                                <input type="hidden" value="@(Math.Round(product.PreferentialPrice,2))" id="preferentitalprice_@(product.Id)" />
                                                <span style="font-weight: bold; font-style: normal; text-decoration: none; color: rgb(255, 68, 0); font-size: 14px; min-width: 100px;" id="item-row__price-item_@(product.Id)" name="item_row_price">@(Math.Round(product.PreferentialPrice * quantity, 2))</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div data-halo-type="flex">
                        <div style="display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; margin: 0px; padding: 0px; background-color: rgb(242, 247, 255); border-bottom: 1px dotted rgb(128, 178, 255);">
                            <div style="padding: 0px; border-top: 1px solid rgb(255, 255, 255);">
                                <div data-halo-type="flex">
                                    <div style="display: grid; grid-template-columns: 1fr 1fr; margin: 0px;">
                                        <div style="padding: 0px; border-right: 1px solid rgb(255, 255, 255); border-top: 1px solid rgb(255, 255, 255);">
                                            <div data-halo-type="flex">
                                                <div style="display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; margin: -5px 0px; padding: 0px;">
                                                    <div style="padding: 5px; border-top: 1px solid rgb(255, 255, 255);">
                                                        <div data-halo-type="textArea">
                                                            <div class="textarea">
                                                                <label class="textarea__title">
                                                                    <div>给卖家留言：</div>
                                                                </label>
                                                                <div class="textarea__wrapper">
                                                                    <span class="next-input next-input-textarea textarea__input">
                                                                        <textarea placeholder="选填，请先和商家协商一致，付款后商家可见" id="textarea_@(product.Id)" name="textarea_@(product.Id)" maxlength="200" data-real="true" rows="1">@(remark)</textarea>
                                                                        <span class="next-input-control"><span class="next-input-len">0/200</span></span>
                                                                    </span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div style="padding: 0px; border-right: 1px solid rgb(255, 255, 255); border-top: 1px solid rgb(255, 255, 255);">
                                            <div data-halo-type="flex">
                                                <div style="display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; margin: -5px 0px; padding: 0px;">
                                                    <div style="padding: 5px; border-top: 1px solid rgb(255, 255, 255);">
                                                        <div data-halo-type="deliveryMethod">
                                                            <div class="delivery-method">
                                                                <div class="delivery-select">
                                                                    <span class="delivery-title">运送方式：</span>
                                                                    <div class="delivery-box">
                                                                        <span class="single-method">
                                                                            <label class="title-text">普通配送</label>
                                                                            <label class="delivery-type"></label>
                                                                            <span>快递￥10.00</span>
                                                                        </span>
                                                                        <div class="appoint-container"></div>
                                                                    </div>
                                                                </div><span class="select-price" style="color: rgb(255, 80, 0);">10.00</span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div style="padding: 5px; border-top: 1px solid rgb(255, 255, 255);">
                                                        <div data-halo-type="postageInsurance">
                                                            <div class="order-postageInsurance">
                                                                <div class="user-title">运费险：</div>
                                                                <div class="user-operate">
                                                                    <label class="next-checkbox-wrapper ins-checkbox ">
                                                                        <span class="next-checkbox">
                                                                            <span class="next-checkbox-inner"><i class="next-icon next-icon-select next-xs"></i></span>
                                                                            <input type="checkbox" aria-checked="false" class="next-checkbox-input">
                                                                        </span>
                                                                        <span class="next-checkbox-label">
                                                                            <span class="trigger">运费险</span>
                                                                            <div class="user-content">退换货可赔付10元</div>
                                                                        </span>
                                                                    </label>
                                                                    <span class="widget-tips-box">
                                                                        <img src="~/imgs/others/msg.png" class="wtip-icon">
                                                                        <div class="wtip-msg-box  wtip-msg-right">
                                                                            <div class="wtip-arrow-icon"></div>
                                                                            <div class="">退换货可赔付10元</div>
                                                                        </div>
                                                                    </span>
                                                                    <a href="##" target="_blank" class="ins-question widget-tips-question">
                                                                        <img class="ins-question-icon" src="~/imgs/others/ask.png">
                                                                    </a>
                                                                </div>
                                                                <div class="user-price">0.00</div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div><div style="padding: 0px; border-top: 1px solid rgb(255, 255, 255);">
                                <div data-halo-type="flex">
                                    <div style="display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; margin: 0px; padding: 10px 0px;">
                                        <div style="padding: 0px;">
                                            <div data-halo-type="label">
                                                <div class="label ">
                                                    <span class="label__header" style="font-weight: normal; font-style: normal; text-decoration: none; font-size: 14px; min-width: 100px; margin-right: 10px;">店铺合计(含运费)</span>
                                                    <span style="font-weight: bold; font-style: normal; text-decoration: none; color: rgb(255, 68, 0); font-size: 14px; min-width: 100px;" id="total_price1">￥@(Math.Round(product.PreferentialPrice * quantity, 2))</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div style="padding: 0px;">
                                            <div data-halo-type="descriptionGroup"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            }
        }


        <div data-halo-id="realPayPC_1" data-halo-type="realPay">
            <div class="realpay order-payInfo" id="realPayPC_1">
                <div class="box">
                    <div class="box__wrapper">
                        <div class="box__shadow">
                            <div>
                                <span class="realpay--title">实付款：</span>
                                <span class="realpay--price-symbol">¥</span>
                                <span class="realpay--price" style="color: rgb(255, 80, 0);" id="total_price2">@(Math.Round(total, 2))</span>
                            </div>
                            <div class="order-confirmAddr">
                                <div class="confirmAddr-addr">
                                    <span class="confirmAddr-title">寄送至：</span>
                                    <span class="confirmAddr-addr-bd">@defaultAddr.ToString();</span>
                                </div>
                                <div class="confirmAddr-addr-user">
                                    <span class="confirmAddr-title">收货人：</span>
                                    <span class="confirmAddr-addr-bd">@defaultAddr.Name @defaultAddr.Phone</span>
                                </div>
                            </div>
                            <div class="order-confirm-eticket"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div data-halo-id="submitOrderPC_1" data-halo-type="submitOrder">
            <div class="submitOrder-container" id="submitOrderPC_1">
                <div class="wrapper">
                    <a class="go-back" target="_self" role="button" title="返回购物车" href="//cart.taobao.com/cart.htm">返回购物车</a>
                    <input type="submit" title="提交订单" class="go-btn" style="background-color: rgb(255, 80, 0);border-width:0px;margin-top:5px;" value="提交订单"></input>
                </div>
                <div class="base-msg">若价格变动，请在提交订单后联系卖家改价，并查看已买到的宝贝</div>
            </div>
        </div>
    </form>
</div>
<script src="~/js/shop.js"></script>